<?php
class Vacancy_Model_Tree extends Zen_Tree {
	
	public function __construct() {
		$table = new Zend_Db_Table ( 'vacancy_tree' );
		$this->table = $table;
		$types=array(
			'root'=>array(
				'icon'=>'/cms/res/icons/drive.png',
				'label'=>'Вакансии',
				'valid_children'=>array('city'),
				'start_drag'=>false,
				'move_node'=>false,
				'delete_node'=>false,
				'remove'=>false
				),
			'city'=>array(
				'form' => 'Vacancy_Form_City',
				'table' => 'vacancy_city',
				'label'=>'город',
				'icon'=>'/cms/res/icons/map.png',
				'valid_children'=>array('item'),
				'start_drag'=>true,
				'move_node'=>true,
				'delete_node'=>true,
				'remove'=>true
				),
			'item'=>array(
				'form' => 'Vacancy_Form_Item',
				'table' => 'vacancy_item',
				'label'=>'должность',
				'icon'=>'/cms/res/icons/user_suit.png',
				'valid_children'=>'none',
				'start_drag'=>true,
				'move_node'=>true,
				'delete_node'=>true,
				'remove'=>true
				)						
		);
		$this->setTypes ( $types );
	}
	
	public function getTree() {
		$res = $this->select()
					->setParentId(0)
					->setPlain(false)
					->setDepth(0)
					->setColumns(array(
						'tree'=>array('id','parent_id',),
						'city'=>array('label',),
						'item'=>array('label','email','acting','requirements','terms','type','contacts','dopinfo',),
					))
					->setOrder('tree.left')
					->getData();
		return $res;
	}
	
}